package com.woniuxy.dr_mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.dr_mall.entity.DrRegion;
import com.woniuxy.dr_mall.mapper.DrRegionMapper;
import com.woniuxy.dr_mall.service.IDrRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.swing.plaf.synth.Region;
import java.util.List;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
@Service
public class DrRegionServiceImpl extends ServiceImpl<DrRegionMapper, DrRegion> implements IDrRegionService {
    @Autowired
    private DrRegionMapper drRegionMapper;

    //通过pid查询地区信息
    @Override
    public List<DrRegion> usePidSelect(int pid) {
        return drRegionMapper.usePidSelect(pid);
    }


    @Override
    public List<DrRegion> getProvince() {
        return drRegionMapper.getPidIsNull();
    }

    @Override
    public List<DrRegion> getByPid(Integer pid) {
        return drRegionMapper.getByPid(pid);
    }

    @Override
    public DrRegion getById(Integer id) {
        return drRegionMapper.getById(id);
    }

    @Override
    public int getIdByName(String name) {
        Integer id = drRegionMapper.getIdByName(name).getId();
        System.out.println(id);
        if (id == null || id.equals(null)){
            id = 0;
        }
        return id;
    }
}
